<?php
class CityInput extends CInputWidget{
	private $language = 'zh_CN';
	public function init()
	{
		list($name, $id) = $this->resolveNameID();
		if($this->hasModel()){
			$attribute=$this->attribute;
           
			$city_id = $this->model->$attribute;
            $aCityData = Yii::app()->common->getCity();
            $value = '';
            $proviceid = 0;
            $aAllId = array();
            if( $aCityData ){
                foreach( $aCityData as $apval ){
                    $aCity = $apval['child'];
                    if( $aCity ){
                        foreach( $aCity as $ackey=>$acval ){
                            if( $ackey==$city_id ){
                                $proviceid = $acval['pid'];
                            }
                        }
                    }
                }            
            }
            $value = $proviceid . ',' . $city_id;
		}else{
			$value = $this->value;
		}
		$this->render('index',array('name'=>$name,'id'=>$id,'value'=>$value));
	}
}
?>